package Day;

import java.util.*;

public class Day6 {

    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int m= in.nextInt();
        int []num=new int[100000];
        PriorityQueue<Integer>queue=new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            int t=in.nextInt();
            num[t]++;
        }
        for (int i = 0; i <100000; i++) {
            if(num[i]!=0){
                queue.offer(num[i]);
            }
        }
        while (queue.size()<m-1){
            if (queue.peek()%2==0){
                int f=queue.poll()/2;
                queue.offer(f);
                queue.offer(f);
            }else {
                int f=queue.poll()/2;
                queue.offer(f);
                queue.offer(f+1);
            }
        }
        System.out.println(queue.poll());

    }


static class ss implements Comparable<ss>{
    int x;

    public ss(int x) {
        this.x = x;
    }

    @Override
    public int compareTo(ss o) {
        return this.x -o.x;
    }
}

    public static void main3(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int m= in.nextInt();
        int []num=new int[100000];
        PriorityQueue<ss>queue=new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            int t=in.nextInt();
            num[t]++;
        }
        for (int i = 0; i <100000; i++) {
            if(num[i]!=0){
                ss s=new ss(num[i]);
             queue.offer(s);
            }
        }
        while(queue.size()<m-1){
            if(queue.peek().x%2==0){
                ss f= new ss(queue.poll().x/2);
                queue.offer(f);
                queue.offer(f);
            }else {
                ss f= new ss(queue.poll().x/2);
                ss f1= new ss( (queue.poll().x/2)+1);

                queue.offer(f);
                queue.offer(f1);
            }
        }
        System.out.println(queue.peek().x);
    }


    public static void main2(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int m=in.nextInt();
        HashMap<Integer,Integer> hashMap=new HashMap();
        for (int i = 0; i <n ; i++) {
            int x= in.nextInt();
            hashMap.getOrDefault(x,hashMap.get(x)+1);
        }

    }





    public static void main1(String[] args) {
        Scanner in=new Scanner(System.in);
       long x=in.nextLong();
        long a=(int)Math.pow(x,0.5);
        long b=a+1;
        long y=Math.abs(a*a-x)<Math.abs(b*b-x)?a*a:b*b;
        System.out.println(y);
    }
}
